package main

import "fmt"

func main() {
	fmt.Println(sum())
	fmt.Println(sum(3))
	fmt.Println(sum(1, 2, 3))

	arr := []int{1, 2, 3, 4, 5}
	fmt.Println(sum(arr...))

	fmt.Printf("%T\n", f)
	fmt.Printf("%T\n", g)
}

func sum(vals ...int) int {
	total := 0
	for _, val := range vals {
		total += val
	}
	return total
}

// 变长参数和slice参数看起来很像，但实际是不同的类型
func f(...int) {}

func g([]int) {}
